using Microsoft.IdentityModel.Protocols.WSTrust;
using System;
using System.Security;
using System.Security.Permissions;
namespace Net35.Xrm.Sdk.Client
{
	[SecuritySafeCritical]
	[SecurityPermission(SecurityAction.Demand, Unrestricted = true)]
	internal sealed class LiveIdRequestSecurityTokenSerializer : WSTrustFeb2005RequestSerializer
	{
		private string _policy = string.Empty;
		public LiveIdRequestSecurityTokenSerializer(string policy)
		{
			ClientExceptionHelper.ThrowIfNullOrEmpty(policy, "policy");
			this._policy = policy;
		}
		public override void WriteXmlElement(System.Xml.XmlWriter writer, string elementName, object elementValue, RequestSecurityToken rst, WSTrustSerializationContext context)
		{
			base.WriteXmlElement(writer, elementName, elementValue, rst, context);
			if (string.Compare(elementName, "appliesto", StringComparison.OrdinalIgnoreCase) == 0)
			{
				writer.WriteStartElement("wsp", "PolicyReference", LiveIdAuthenticationConfiguration.PolicyReference);
				writer.WriteAttributeString("URI", this._policy);
				writer.WriteEndElement();
			}
		}
	}
}
